from fastapi import APIRouter
from typing import Optional,Union
query_parameter = APIRouter()

# 查询参数 Optional[str] = None ==  Union[int, str] 
@query_parameter.get("/items/")
def read_item(item_id: Union[int, str], q: Optional[str] = None):
    return {"item_id": item_id, "q": q}

@query_parameter.get("/users/")
def read_user(user_id: int, q: str = None):
    return {"user_id": user_id, "q": q}


